<?php require RCMS_Object_QuickConfig_QuickConfig::PATH_HEADER; ?>
<?php $this->headLink()->appendStylesheet($this->websiteUrl . 'system/css/seotoaster.css'); ?>
<?php $this->headLink()->appendStylesheet($this->websiteUrl . 'system/css/jquery-ui-theme/jquery-ui-1.8.5.custom.css');?>
<?php echo $this->headLink(); ?>
<?php $this->headScript()->prependFile((false !== @file_get_contents(RCMS_Object_QuickConfig_QuickConfig::G_JQ_HOSTED_URL)) ? RCMS_Object_QuickConfig_QuickConfig::G_JQ_HOSTED_URL : $this->websiteUrl . 'system/js/jquery/jquery.js'); ?>
<?php $this->headScript()->appendFile((false !== @file_get_contents(RCMS_Object_QuickConfig_QuickConfig::G_JQUI_HOSTED_URL)) ? RCMS_Object_QuickConfig_QuickConfig::G_JQUI_HOSTED_URL : $this->websiteUrl . 'system/js/jquery/jquery-ui.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/shopping/shopping.js'); ?>
<?php $this->headScript()->appendFile($this->websiteUrl . 'system/js/jquery/plugins/jquery.lazyload.js'); ?>
<?php echo $this->headScript(); ?>
<script type="text/javascript">window.onload = function(){ var params = { websiteurl : '<?php echo $this->websiteUrl; ?>' }; shop.init(params); <?php if ($this->productId > 0): ?>shop.getDataProductForForm(<?php echo $this->productId; ?>);<?php endif; ?> }</script>
<div id="seotoaster" class="product">
<div class="admineditwhat">{%Add%} / {%Edit%} / {%Remove Products%}</div>
<div class="close_window" onclick="parent.tb_remove();"></div>

<div class="header">
    <div class="addorselectproduct">
        <span style="border-right:1px solid #fff;" onclick="shop.resetFormAddProduct();">{%Add a new product%}</span>
        <span style="border-right:1px solid #fff;" onclick="$('#prodlist').toggle();">{%Edit a product from the list%}</span>
		<input type="hidden" id="producttodel" value='' />
        <span style="float:right;color:#ddd;" onclick="var val=document.getElementById('producttodel').value;if(val > 0){if(confirm('{%Do you really want to delete this product%}?')){shop.deleteProduct(val);}}">{%Delete this product%}</span>
    </div>
</div>
	<div id="prodlist">
		<div id="prodlist-search">
		Search: <input type="text" name="filterproduct" id="filterproduct" value="{%by name or id%}" title="{%by name or id%}" style="color:#7c7c7c;" />
		</div>
		<ul id="shopproducts">
			<?php if (is_array($this->products) && count($this->products) > 0): ?>
				<?php foreach ($this->products as $product) : ?>
				<li class="shoproductlisting" id="<?php echo $product['id']; ?>">
					<a href="#" onclick="shop.getDataProductForForm(<?php echo $product['id'];?>);">
						<span class="shoproductlistingid"><?php echo $product['item_id']; ?></span>
					<img class="post-load" width="100px" src="<?php echo $this->websiteUrl . $product['photo']; ?>" alt="<?php echo $product['item_id'];?>" />
					<span><?php echo (strlen($product['name']) <= 25 ? $product['name'] : substr($product['name'],0,25).'...');?></span></a>
				</li>
				<?php endforeach; ?>
			<?php endif; ?>
		</ul>
	</div>

<div class="errors" id="message" style="background-color:green;display: none;" onclick="this.style.display='none';"></div>
<div id="list_images"></div>

<div class="body">
    <div id="viewpage" style="display: none;">
       <a href="#" target="blank">{%View product page%}</a>
   </div>
    <div class="block1">
    	 <form name="add_product" id="add_product" action="javascript:;" style="margin-bottom:10px">
    	 	<fieldset style="position:relative"><legend>{%Required information%}</legend>
	    <div style="float:left;">
            <select id="image_folders" onchange="shop.loadImages(this.options[this.selectedIndex].value);">
                <option value="" selected="selected">select folder</option>
                <?php if(!empty($this->listFolders) && is_array($this->listFolders)): ?>
                    <?php foreach($this->listFolders as $folderName): ?>
                     <option value="<?php echo trim($folderName); ?>"><?php echo $folderName; ?></option>
                    <?php endforeach; ?>
                <?php endif; ?>
            </select>
            <div id="showimage" align="center"><p>{%No Image%}</p>
			</div>

        </div>

        <div style="float:left;margin-left:10px; width: 59%">
            <div>{%Name%}: *<br /><input type="text" name="name" value="" /></div>
            <div style="width: 44%; display: inline-block;">{%Item Id%}: *<br /><input type="text" name="item_id" value="" style="width: 95px;"/></div>
            <div style="width: 50%; display: inline-block;">{%Weight%}:&nbsp;<br /><input type="text" name="weight" value="" style="width: 95px;"/>&nbsp;<?php $shippingGeneral = unserialize($this->shoppingConfig['shipping_general']); echo $shippingGeneral['weight-units'];?></div>
            <div>{%MPN%}: <br /><input type="text" name="mpn" value="" /></div>
			<div>{%Brand%}: <br /><input id="brands-autocomplete" type="text" name="brand" value="" /></div>
            <div style="width: 54%; display: inline-block; overflow: visible; ">{%Price%}: *<br /><input type="text" name="price" value="" onfocus="$('#price-tip').fadeIn();" onblur="$('#price-tip').fadeOut();" style="width: 90px;"/>&nbsp;<?php echo $this->shoppingConfig['currency'];?></div>
            <div style="width: 44%; display: inline-block;">
                <select name="tax" id="tax" style="width:100px;padding:3px 5px 3px 0px;">
                    <?php $labels = unserialize($this->shoppingConfig['tax-labels']);?>
                    <?php foreach ($labels as $id => $label) : ?>
                        <option value="<?php echo $id;?>"><?php echo $label;?></option>
                    <?php endforeach; ?>
                </select>
            </div>

            <div style="display: inline-block; width: 99%;"><input type="checkbox" name="onsale" value="" id="onsale" style="vertical-align: middle;"/>&nbsp;{%Make a Special Offer%}</div>
			<div class="saleit" style="display: inline-block; width: 99%;">
                {%Sale price%}:
				<input type="text" name="salePrice" id="sale-price" value="" onfocus="$('#sale-price-tip').fadeIn();" onblur="$('#sale-price-tip').fadeOut();" style="width: 120px;" /> <?php echo $this->shoppingConfig['currency'];?>
            </div>
			<div class="saleit" style="display: inline-block; width: 99%;">
                {%Expiry date%}:
				<input type="text" name="saleExp" id="sale-expire" value="" style="width: 120px;" onfocus="$('#expire-date-tip').fadeIn();" onblur="$('#expire-date-tip').fadeOut();"/>
            </div>

        </div>
		<div style="clear:both;"></div>

		<script type="text/javascript">
			$(function(){
				$('#desc-tabs').tabs();
			});

		</script>

		<div id="desc-tabs" style="padding: 0px; border: 0px;">
			<ul style="background: none; border: 0px; padding: 0px;">
				<li><a style="padding: 2px;" href="#short-desc" title="{%Short description%}">{%Short description%}</a></li>
				<li><a style="padding: 2px;" href="#full-desc" title="{%Full description%}">{%Full description%}</a></li>
			</ul>
			<div id="short-desc" style="padding: 0px;">
				<textarea name="description" cols="45" rows="5"></textarea>
			</div>
			<div id="full-desc" style="padding: 0px;">
				<textarea name="fullDescription" cols="45" rows="5"></textarea>
			</div>
		</div>

        <div>
            <input type="hidden" name="image" value="" />
            <input type="hidden" name="id" value="0" />
        </div>

        <div><a  onclick="shop.addOption();" style="cursor:pointer;" alt="add one more option for this product"><img src="<?php echo $this->websiteUrl; ?>system/images/ico_plus_green.gif" />  {%Add one more options row%} <small>({%Maximum%} 3)</small></a></div>

        <div id="product_options">
          <p><img src="<?php echo $this->websiteUrl; ?>system/images/ico_del_green.gif" alt="delete option"  onclick="this.parentNode.parentNode.removeChild(this.parentNode);" /> <input type="text" /> <input type="text" /></p>
        </div>
    </fieldset></form>
	</div><!-- End Block1 -->

    <div class="block2">
        <script type="text/javascript">
            $(document).ready(function(){
                $("#tabs").tabs();
            });
        </script>
        <div id="tabs" style="padding: 0">
            <ul style="background: none repeat scroll 0% 0% transparent; border: none; border-bottom: 1px solid #7c7c7c">
                <li><a href="#related" title="{%Related Products%}">{%Related Products%}</a></li>
                <li><a href="#freebiez" title="{%Freebies%}">{%Freebies%}</a></li>
            </ul>

            <div id="related" class="tab" style="position: relative;">
				<p>
					<input type="text" class="autocomplete" name="relateds-autocomplete" style="width: 100%" value="{%Start typing name of product%}" title="{%Start typing name of product%}"/>
				</p>
                <div id="relateds" class="hooked_prods"></div>
            </div>

            <div id="freebiez" class="tab" style="position: relative;">
				<p>
					<input type="text" class="autocomplete" name="freebies-autocomplete" style="width: 100%" value="{%Select items to throw in with for free%}" title="{%Select items to throw in with for free%}" />
				</p>
                <div id="freebies" class="hooked_prods"></div>
				<div id="freebie-tip" style="font-size: 80%; text-align: center" class="ui-state-highlight ui-corner-all">{%Check "Make a Special Offer" to see your freebies promotion go live%}</div>
            </div>


        </div>
		<fieldset style="position:relative"><legend>{%Products Categories%}</legend>
        <div>
            <form action="javascript:;">
                <p><input type="text" name="addgroup" />
                    <input type="button" value="{%Add%}" onclick="shop.addGroup(this.form.addgroup.value);this.form.addgroup.value ='';" /></p>
            </form>
            <div id="groups">
                <?php if(is_array($this->groups) && count($this->groups) > 0): ?>
                <?php foreach ($this->groups as $group): ?>
                <div id="<?php echo 'group-'.$group['id']; ?>"><input type="checkbox" />
					<img title="delete <?php echo $group['name']; ?>" onclick="if(confirm('You want delete this group?')){shop.deleteGroup('<?php echo $group['id']; ?>');}" src="<?php echo $this->websiteUrl; ?>system/images/ico_delete.gif" />
					<section class="group-editable" groupid="<?php echo $group['id']; ?>" title="<?php echo $group['name']; ?>" contenteditable="true"><?php echo substr($group['name'],0,12); ?></section>
				</div>
                <?php endforeach; ?>
                <?php endif; ?>
            </div>
        </div>
		</fieldset>

    </div>

</div>
<ul id="tooltip" style="bottom:10px;left:10px;position:absolute; width: 70%; list-style: none;">
    <li id="price-tip" class="ui-state-highlight ui-corner-all" style="display: none">
        <span class="ui-icon ui-icon-info" style="float: left"></span>
        <span>
        {%Always set product price without tax in this field.%} <br/>
        {%Go to tax config menu in order to set tax rates and price display option (inc. tax or before tax).%}
        </span>
    </li>
    <li id="zero-price-tip" class="ui-state-error ui-corner-all" style="display: none">
        <span class="ui-icon ui-icon-info" style="float: left"></span>
        <span>
        {%If you leave sale price field blank, the product is free. Are you sure this is what you want to do?%}
        </span>
    </li>
    <li id="sale-price-tip" class="ui-state-highlight ui-corner-all" style="display: none">
        <span class="ui-icon ui-icon-info" style="float: left"></span>
        <span>
        {%Sale price gets displayed on top of strike-through regular price.  Leave sale price field blank to offer this product free.%}<br />
		{%Set sale price to match regular price if you want to set an expiry date for freebies only. No struck-through price in that case.%}
        </span>
    </li>
    <li id="expire-date-tip" class="ui-state-highlight ui-corner-all" style="display: none">
        <span class="ui-icon ui-icon-info" style="float: left"></span>
        <span>
        {%Leave the expiry date blank when your sale and/or freebies offers are permanent.%}
        </span>
    </li>
</ul>
<input type="button" class="formsubmit" id="submitform" value="{%Done%}" onclick="shop.addProduct();" />
</div>
<script type="text/javascript">
	$('div.saleit').hide();
	$('#sale-expire').datepicker({dateFormat: 'yy-mm-dd'});
	$('#onsale').click(function(){
		$('.saleit > input').val('');
		$('.saleit').toggle();
		$('#sale-price').val($('input[name="price"]').val());
		if ($(this).attr('checked')) {
			$('#tabs').tabs("select","#freebiez");
			$('#freebie-tip').hide();
		} else {
			$('#freebie-tip').show();
		}
	});
	$('#sale-price').blur(function(){
		if ($(this).val()=='') {
			$('#zero-price-tip').fadeIn();
		} else {
			$('#zero-price-tip').fadeOut();
		}
	})

		$('img.post-load').lazyload({ 
             effect      : "fadeIn",
             container: $("#prodlist")
        });
        $(function(){
           $('#prodlist').hide(); 
        });

</script>